﻿// ------------------------------------------------------------------------------------
//      Copyright (c) 2012 uhavemyword@gmail.com. All rights reserved.
//      Created by Ben at 12/24/2012 7:13:16 PM
// ------------------------------------------------------------------------------------

namespace CP.NLayer.Data
{
    using System.Data.Entity;
    using System.Data.Entity.Infrastructure;
    using System.Xml;

    public class MyDbUtility
    {
        public static void InitializeDatabase()
        {
            Database.SetInitializer<MyDbContext>(new MyDbInitializer());
            var context = new MyDbContext();
            context.Database.Initialize(false);
        }

        public static void WriteEdmx(string filePath)
        {
            var context = new MyDbContext();
            var settings = new XmlWriterSettings();
            settings.Indent = true;
            var writer = XmlWriter.Create(filePath, settings);
            EdmxWriter.WriteEdmx(context, writer);
        }
    }
}